﻿Imports System.Data.OleDb

Public Class frmEdicionAtencion

    Private Sub bt_guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_guardar.Click
        Dim controles As String
        controles = ""
        controles = ControlCamposIncompletos(Gb_01) + controles
        controles = ControlCamposIncompletos(Gb_03) + controles

        If controles <> "" Then
            MsgBox("Le falto completar datos en: " & Chr(13) & controles, MsgBoxStyle.Critical, "ERROR!")
        Else
            IDentificadorUnico(lblIdunicoLlam)
            titulo(Gb_01)
            titulo(Gb_02)
            If chkAlerta.Checked = True Then
                Dim correoDestino As String
                correoDestino = getEmailDestino(cbo_empresa.Text)
                enviarAlerta(correoDestino, cbo_controla.Text, cbo_auditado.Text, txtCaso.Text, cboLoteLetra.Text + cboLoteNum.Text, dtp_fllam.Text, lbl_puntaje.Text, rtxt_encontra.Text)
            End If
            Dim guardar As New C_agregarDatos
            guardar.guardarLLamada()
            Psaludo = 0
            Pempatia = 0
            Pindagacion = 0
            Pdisposicion = 0
            Pcompromiso = 0
            Pinformacion = 0
            Pcomunicacion = 0
            Pcierre = 0
            TodoACero()
        End If
    End Sub
    Private Sub bt_nAuditado_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmNewAuditado.ShowDialog()
    End Sub
    Private Sub bt_nControler_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmNewControlador.ShowDialog()
    End Sub

    Private Sub frm_inicio_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        For i = 0 To 100
            cboLoteNum.Items.Add(i)
        Next i
        puntajeTotal = 0
        CargarEmpresas(cbo_empresa)
        CargarAuditor(cbo_controla)
        CargarTllamada(cbo_tllamada)
        CargarOptSalu(cbo_salu)
        CargarOptEmpa(cbo_empatia)
        CargarOptInd(cbo_indagacion)
        CargarOptDisp(cbo_disposicion)
        CargarOptComp(cbo_compromiso)
        CargarOptInfo(cbo_info)
        CargarOptComunicacion(cbo_comunicacion)
        CargarOptCredibilidad(cbo_credibilidad)
        CargarOptClose(cbo_cierre)
        dtp_hoy.Value = Today
        lbl_puntaje.Text = puntajeTotal
        TodoACero()
        chkAlerta.Checked = False

        If cbo_empresa.Text = "Seleccionar..." Then
            cbo_auditado.Enabled = False
        End If
    End Sub

    Private Sub cbo_salu_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_salu.SelectedIndexChanged
        Dim valorSal As New C_todos
        Psaludo = valorSal.valorSalu(cbo_salu)
        txtv01.Text = Psaludo
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub

    Private Sub cbo_empatia_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_empatia.SelectedIndexChanged
        Dim valorEmp As New C_todos
        Pempatia = valorEmp.valorEmpatia(cbo_empatia)
        txtv02.Text = Pempatia
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub

    Private Sub cbo_indagacion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_indagacion.SelectedIndexChanged
        Dim valorInd As New C_todos
        Pindagacion = valorInd.valorIndagacion(cbo_indagacion)
        txtv03.Text = Pindagacion
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub

    Private Sub cbo_disposicion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_disposicion.SelectedIndexChanged
        Dim valorDisp As New C_todos
        Pdisposicion = valorDisp.valordisposicion(cbo_disposicion)
        txtv04.Text = Pdisposicion
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub

    Private Sub cbo_compromiso_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_compromiso.SelectedIndexChanged
        Dim valorComp As New C_todos
        Pcompromiso = valorComp.valorCompromiso(cbo_compromiso)
        txtv05.Text = Pcompromiso
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub

    Private Sub cbo_info_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_info.SelectedIndexChanged
        Dim valorinf As New C_todos
        Pinformacion = valorinf.valorinformacion(cbo_info)
        txtv06.Text = Pinformacion
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub

    Private Sub cbo_comunicacion_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_comunicacion.SelectedIndexChanged
        Dim valorComunic As New C_todos
        Pcomunicacion = valorComunic.valorComunicacion(cbo_comunicacion)
        txtv07.Text = Pcomunicacion
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub

    Private Sub cbo_credibilidad_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_credibilidad.SelectedIndexChanged
        Dim valorCredi As New C_todos
        Pcredibilidad = valorCredi.valorCredibilidad(cbo_credibilidad)
        txtv08.Text = Pcredibilidad
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub

    Private Sub cbo_cierre_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_cierre.SelectedIndexChanged
        Dim valorClouse As New C_todos
        Pcierre = valorClouse.valorClose(cbo_cierre)
        txtv09.Text = Pcierre
        puntajeTotal = 0
        puntajeTotal = Psaludo + Pempatia + Pindagacion + Pdisposicion + Pcompromiso + Pinformacion + Pcomunicacion + Pcredibilidad + Pcierre
        lbl_puntaje.Text = puntajeTotal
    End Sub
    Private Sub LlamadasPorNºDeLoteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmInfoAsesorAtencion.ShowDialog()
    End Sub

    Private Sub bt_nEmpresa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frm_empresa.ShowDialog()
    End Sub

    Private Sub cbo_empresa_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        CargarAudiXempresa(cbo_auditado)
    End Sub

    Private Sub dtp_fllam_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If dtp_fllam.Value > Today Then
            MsgBox("La fecha de llamada no puede ser mayor al día Actual")
            dtp_fllam.Value = Today
        End If
    End Sub

    Private Sub EditarLlamadasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmSearchLlamadas.ShowDialog()
    End Sub

    Private Sub RankingDePromediosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmInfoRankingAtencion.ShowDialog()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim yes As Integer
        yes = MsgBox("Seguro desea salir de la auditoria de ATENCION?" & Chr(13) & "Los datos se perderan al no ser guardados", MsgBoxStyle.YesNo, "Volver")
        If yes = 6 Then
            TodoACero()
            ' frmIndex.Show()
            Me.Close()
        End If
    End Sub

    Private Sub TodoACero()
        Limpiar(Gb_01)
        Limpiar(Gb_02)
        Limpiar(Gb_03)
        Limpiar(gbValores)

        Psaludo = 0
        Pempatia = 0
        Pindagacion = 0
        Pdisposicion = 0
        Pcompromiso = 0
        Pinformacion = 0
        Pcomunicacion = 0
        Pcredibilidad = 0
        Pcierre = 0
        puntajeTotal = 0
        lbl_puntaje.Text = 0
        chkAlerta.Checked = False
    End Sub

    Private Sub cbo_empresa_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbo_empresa.SelectedIndexChanged
        auditadosXempresaVentas(cbo_auditado, cbo_empresa.Text)
        cbo_auditado.Enabled = True
        cbo_auditado.Text = "Seleccionar..."
    End Sub

End Class
